using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GameManager : MonoBehaviour {
	 
	GUIStyle style;
	public List<GameObject> slabZoneList;
	public List<GameObject> trashZoneList;
	
	void Awake () {
		Application.targetFrameRate = 100;
//		DontDestroyOnLoad(this);
	}
	
	// Use this for initialization
	void Start () {
		style = new GUIStyle();
		style.normal.textColor = Color.black;
		
		slabZoneList = new List<GameObject> ();
		trashZoneList = new List<GameObject> ();
		
	}
	
	// Update is called once per frame
	void Update () {
		
		int count = slabZoneList.Count + trashZoneList.Count;
		
		if(count == 8) {
			Debug.Log("You win !");
			StartCoroutine(MyLoadLevel(1.0f, 1));
		}
		
	}
	
	IEnumerator MyLoadLevel(float delay, int level)
	{
	    yield return new WaitForSeconds(delay);
	    Application.LoadLevel(level);
	}
	
	IEnumerable loadLevel () {
		yield return new WaitForSeconds(2);
		Application.LoadLevel("Slab");
	}


	public List<GameObject> SlabZoneList {
		get {
			return this.slabZoneList;
		}
		set {
			slabZoneList = value;
		}
	}

	public List<GameObject> TrashZoneList {
		get {
			return this.trashZoneList;
		}
		set {
			trashZoneList = value;
		}
	}
	
	void OnGUI () {
		GUI.Label(new Rect(10, 10, 800, 20), "Move slabs in GREEN zone by dragging them with LEFT click. Do the same with NON-slabs objects to RED zone", style);
		GUI.Label(new Rect(10, 30, 600, 20), "Turn over scene using MIDDLE click", style);
		GUI.Label(new Rect(10, 50, 600, 20), "Resize objects (slab only) by a pressed RIGHT click on slabs faces + drag move.", style);
		
		
		if (GUI.Button(new Rect(Screen.width - 110, 10, 100, 30), "Reload scene"))
            Application.LoadLevel(0);
	}
	
}
	
	
